//
//  NIMInputMoreContainerView+ZLCustom.m
//  ZLYoYoIM_Example
//
//  Created by 赵磊 on 2021/1/18.
//  Copyright © 2021 itzhaolei. All rights reserved.
//

#import "NIMInputMoreContainerView+ZLCustom.h"
#import "ZLSessionConfig.h"

@implementation NIMInputMoreContainerView (ZLCustom)

- (void)genMediaButtons {
    NSMutableArray *mediaButtons = [NSMutableArray array];
    NSMutableArray *mediaItems = [NSMutableArray array];
    NSArray *items;
    if (!self.config) {
        items = [[ZLSessionConfig new] mediaItems];
    } else if([self.config respondsToSelector:@selector(mediaItems)]) {
        items = [self.config mediaItems];
    }
    [items enumerateObjectsUsingBlock:^(NIMMediaItem *item, NSUInteger idx, BOOL *stop) {
        [mediaItems addObject:item];
        UIButton *btn = [[UIButton alloc] init];
        btn.tag = idx;
        [btn setImage:item.normalImage forState:UIControlStateNormal];
        [btn setImage:item.selectedImage forState:UIControlStateHighlighted];
        [btn setTitle:item.title forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [btn setTitleEdgeInsets:UIEdgeInsetsMake(90, -75, 0, 0)];
        [btn.titleLabel setFont:[UIFont systemFontOfSize:14.0]];
        btn.titleLabel.textAlignment = NSTextAlignmentCenter;
        [mediaButtons addObject:btn];
    }];
    [self setValue:mediaButtons forKeyPath:@"_mediaButtons"];
    [self setValue:mediaItems forKeyPath:@"_mediaItems"];
}

@end
